export const uniLoading = (
	promiseResult,
	opts = {
		title: '加载中...',
	}
) => {
	uni.showLoading(opts)
	return promiseResult
		.then((res) => {
			uni.hideLoading()
			return res
		})
		.catch(() => {
			uni.hideLoading()
		})
}

// 自动关闭
export const autoLoading = (opt) => {
	const _opt = Object.assign(
		{
			title: '加载中...',
			interval: 1000,
		},
		opt || {}
	)
	uni.showLoading(_opt)
	setTimeout(() => {
		uni.hideLoading()
	}, _opt.interval || 0)
}
